package com.parktech.sun.web.editor;

import com.parktech.sun.domain.model.BaseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: Think
 * Date: 11-1-9
 * Time: 下午6:35
 */
public class SunBindingInitializer implements WebBindingInitializer {

    private String configLocation;



    public void setConfigLocation(String configLocation) {
        this.configLocation = configLocation;
    }

    public void initBinder(WebDataBinder binder, WebRequest request) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
		binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
		registerAllEntity(binder, request);
	}

    private void registerAllEntity(WebDataBinder binder, WebRequest request) {

    }
}
